import { createRouter, createWebHistory } from 'vue-router'
const Login = () => import(/* webpackChunkName: "login" */ '@/pages/login/index.vue')
const Home = () => import(/* webpackChunkName: "home" */ '@/pages/home/index.vue')
const List = () => import(/* webpackChunkName: "list" */ '@/pages/list/index.vue')
const ListDetail = () => import(/* webpackChunkName: "listDetail" */ '@/pages/listDetail/index.vue')
const Mine = () => import(/* webpackChunkName: "mine" */ '@/pages/mine/index.vue')

// 静态路由
const staticRoutes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    meta: { index: 1 }
  },
  {
    path: '/list',
    name: 'list',
    component: List,
    meta: { index: 1 }
  },
  {
    path: '/listDetail',
    name: 'listDetail',
    component: ListDetail,
    meta: { index: 2 }
  },
  {
    path: '/mine',
    name: 'mine',
    component: Mine,
    meta: { index: 1 }
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
    meta: { index: 1 }
  },
  { path: '/:pathMatch(.*)*', redirect: '/' }
]

const router = createRouter({
  history: createWebHistory(),
  routes: staticRoutes
})

export default router
